﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace TestUp.Models.Helpers
{
    public class PassingResultHelper
    {
        public List<PassingResult> GetUserPassingResults(int userId)
        {
            var userInfo = DataHelpers.UserInfoHelper.GetUserInfo(userId);
            if (userInfo != null)
            {
                return userInfo.PassingResults.ToList();
            }
            return new List<PassingResult>();
        }
        
        public void CreatePassingResult(int userId, int testId, int result)
        {
            var passingResult = new PassingResult
                {
                    UserId = userId,
                    TestId = testId,
                    Result = result,
                    PassingDate = DateTime.Now
                };
            DataWorkItem.Entity.PassingResults.Add(passingResult);
            DataWorkItem.Entity.SaveChanges();
        }
    }
}